.MODEL small
.STACK 1024
.DATA
;const
	fileopen = 3Dh
	fileread = 3Fh
	filewrite = 40h
	fileclose = 3Eh
	filesearch = 42h
	
;var
	
	succesmsg  db "succes$"
	failuremsg db "failure$"
	
	filename db "TEST.TXT",0
	array db 3 dup(?),'$'
	filehandler dw ? 
	endl db 0Ah,0Dh,"$"
;------------- macros -------------
PrintString macro string
	mov ah,09h
		mov dx,offset string
	int 21h
endm

	
.CODE
.STARTUP	
	mov ah,fileopen
		mov al,0
		lea dx,filename
	int 21h
	jnc succes1
	PrintString failuremsg
	jmp failure1
succes1:
	mov filehandler,ax
	PrintString succesmsg
failure1:

	PrintString endl

mov ah,fileread
		mov bx,filehandler
		mov cx,3
		lea dx,array
	int 21h
	jnc succes3
	PrintString failuremsg
	jmp failure3
succes3:
	mov filehandler,ax
	PrintString array
failure3:

	PrintString endl
	
	mov ah,fileclose
		mov bx,filehandler
	int 21h	
	jnc succes2
	PrintString failuremsg
	jmp failure2
succes2:
	mov filehandler,ax
	PrintString succesmsg
failure2:


.EXIT
end
